﻿namespace GreenIsomer.Data.Entities.Ddl {
	using System;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;

	public class TableColumnCollection : Collection<TableColumn> {

		public TableColumnCollection() { }

		public void MergeExtendedDefinition(ExtendedTableDef extendedTableDef) {
			if(extendedTableDef == null) throw new ArgumentNullException("extendedTableDef");

			if(extendedTableDef.DefaultValues.Count == 0) return;

			foreach(TableColumn column in this)
				column.DefaultValue = extendedTableDef.DefaultValues.Find(column.Name);
		}

		public void ReplaceDataTypes(IEnumerable<TypeConversion> typeConversions) {
			if(typeConversions == null) throw new ArgumentNullException("typeConversions");

			foreach(TableColumn column in this) column.ReplaceDataType(typeConversions);
		}

	}

}